<noindex>
    <dl class="widget callme" id="fast-buy">
        <div class="windows-8-loading"></div>
        <dt>Быстрый выбор услуги</dt>
        <dd>
            <form class="fast-buy-service">
                <fieldset>
                    <span class="under-input-text">Тип устройства</span> 
                    <div class="wrap-bg">
                        <ul> 
                            <li>
                                <div class="wrap-bg padding-0">
                                    <div class="select">
                                        <?php
                                        $pageData = Controller::$pageData;
                                        $categoryID = 0;
                                        $brandID = 0;
                                        $modelID = 0;
                                        if ($pageData['pageType'] == 'category') {
                                            $categoryID = isset($pageData['pageId']) ? $pageData['pageId'] : 0;
                                            $brandID = 0;
                                            $modelID = 0;
                                        }

                                        if ($pageData['pageType'] == 'brand') {
                                            $categoryID = isset($pageData['_parents']['category']['pageId']) ? $pageData['_parents']['category']['pageId'] : 0;
                                            $brandID = isset($pageData['pageId']) ? $pageData['pageId'] : 0;
                                            $modelID = 0;
                                        }

                                        if ($pageData['pageType'] == 'model') {
                                            $categoryID = isset($pageData['_parents']['category']['pageId']) ? $pageData['_parents']['category']['pageId'] : 0;
                                            $brandID = isset($pageData['_parents']['brand']['pageId']) ? $pageData['_parents']['brand']['pageId'] : 0;
                                            $modelID = isset($pageData['pageId']) ? $pageData['pageId'] : 0;
                                        }
                                        echo CHtml::dropDownList('category', $categoryID, $options, array('empty' => 'Тип устройства',
                                            'ajax' => array('type' => 'POST',
                                                'url' => Yii::app()->createUrl('main/ajax/getFastBuyData', array('type' => 'brand')),
                                                'update' => '#brands',
                                                'data' => array('id' => 'js:this.value'),
                                                'beforeSend' => 'function(){$(".windows-8-loading").show();}',
                                                'complete' => 'function(){$(".windows-8-loading").hide();}',
                                        )));
                                        ?>                                        										
                                    </div> 
                                </div>
                            </li>
                        </ul> 
                    </div>            
                </fieldset>
                <fieldset>
                    <span class="under-input-text">Производитель</span> 
                    <div class="wrap-bg">
                        <ul> 
                            <li>
                                <div class="wrap-bg padding-0">
                                    <div class="select">
                                        <?php
                                        echo CHtml::dropDownList('brand', $brandID, $this->getBrands($categoryID), array('empty' => 'Производитель', 'id' => 'brands',
                                            'ajax' => array('type' => 'POST',
                                                'url' => Yii::app()->createUrl('main/ajax/getFastBuyData', array('type' => 'model')),
                                                'update' => '#models',
                                                'data' => array('id' => 'js:this.value'),
                                                'beforeSend' => 'function(){$(".windows-8-loading").show();}',
                                                'complete' => 'function(){$(".windows-8-loading").hide();}',
                                        )));
                                        ?>                                        										
                                    </div> 
                                </div>
                            </li>
                        </ul> 
                    </div>            
                </fieldset>
                <fieldset>
                    <span class="under-input-text">Модель</span> 
                    <div class="wrap-bg">
                        <ul> 
                            <li>
                                <div class="wrap-bg padding-0">
                                    <div class="select">
                                        <?php
                                        echo CHtml::dropDownList('model', $modelID, $this->getModels($brandID), array('empty' => 'Модель', 'id' => 'models',
                                            'ajax' => array('type' => 'POST',
                                                'url' => Yii::app()->createUrl('main/ajax/getFastBuyData', array('type' => 'service')),
                                                'update' => '#services',
                                                'data' => array('id' => 'js:this.value'),
                                                'beforeSend' => 'function(){$(".windows-8-loading").show();}',
                                                'complete' => 'function(){$(".windows-8-loading").hide();}',
                                        )));
                                        ?>                                        									
                                    </div> 
                                </div>
                            </li>
                        </ul> 
                    </div>            
                </fieldset>
                <fieldset>
                    <span class="under-input-text">Тип ремонта</span> 
                    <div class="wrap-bg">
                        <ul> 
                            <li>
                                <div class="wrap-bg padding-0">
                                    <div class="select">
                                        <?php
                                        echo CHtml::dropDownList('service', '', $this->getServices($modelID), array('empty' => 'Тип ремонта', 'id' => 'services',
                                            'ajax' => array('type' => 'POST',
                                                'url' => Yii::app()->createUrl('main/ajax/getFastBuyData', array('type' => 'finish')),
                                                'update' => '#finish',
                                                'data' => array('id' => 'js:this.value', 'brand' => 'js:$("#brands").val()', 'model' => 'js:$("#models").val()'),
                                                'beforeSend' => 'function(){$(".windows-8-loading").show();}',
                                                'complete' => 'function(){$(".windows-8-loading").hide();$(".fast-buy-service fieldset:nth-child(5)").show();}',
                                        )));
                                        ?>   

                                    </div> 

                                </div>

                            </li>
                        </ul> 
                    </div>  

                </fieldset>
                <fieldset>
                    <div>
                        <ul> 
                            <li style="list-style: none;">
                                <div style="padding-top: 10px;">
                                    <div>
                                        <div id="finish">
                                            <span>Цена: 1000 руб. </span>
                                            <a href="#">Перейти</a>
                                        </div>										
                                    </div> 
                                </div>
                            </li>
                        </ul> 
                    </div>            
                </fieldset>

            </form>
        </dd>
    </dl>

</noindex>
<style>
    .fast-buy-service fieldset {
        padding-top: 5px;
    }
    .fast-buy-service fieldset:nth-child(5) {
        display: none;
    }
    .under-input-text {
        display: block;
        padding-top: 5px;
    }
</style>
<script>
    $(document).ready(function () {
        $("#category").select2({dropdownCssClass: 'bigdrop'});
        $("#brands").select2({dropdownCssClass: 'bigdrop'});
        $("#models").select2({dropdownCssClass: 'bigdrop'});
        $("#services").select2({dropdownCssClass: 'bigdrop'});
        $('body').on('click', '#service-go', function () {

            var url = window.location.pathname;
            var href = $(this).data('href');
            var u = href.split('#');
            var hash = u[1];

            if (url == '/' + u[0]) {

                $("#click-" + hash).trigger("click");
                $("#service-" + hash).parents("li.hardware-repair__info__item").addClass("search");
                $("#service-" + hash).parents("li.hardware-repair__info__item").addClass("open");
                $("html, body").animate({
                    scrollTop: $("#click-" + hash).offset().top - 20
                }, 1000);
            }


            window.location.href = '/' + $(this).data('href');
            return false;
        });
    });
</script>